Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(megolm): Add mutation tests #142

Merged
merged 7 commits into from
Apr 29, 2024

Conversation

Johennes
Copy link
Contributor

@Johennes Johennes commented Apr 9, 2024

This fixes the following issues:

MISSED   src/megolm/group_session.rs:80:9: replace GroupSession::session_config -> SessionConfig with Default::default() in 0.8s build + 3.1s test
MISSED   src/megolm/inbound_group_session.rs:289:47: replace < with == in InboundGroupSession::find_ratchet in 0.8s build + 3.1s test
MISSED   src/megolm/inbound_group_session.rs:302:9: replace InboundGroupSession::verify_mac -> Result<(), DecryptionError> with Ok(()) in 1.0s build + 3.1s test
MISSED   src/megolm/message.rs:133:9: replace MegolmMessage::add_signature -> Result<(), SignatureError> with Ok(()) in 0.8s build + 3.7s test
MISSED   src/megolm/message.rs:282:42: replace + with - in <impl TryFrom for MegolmMessage>::try_from in 0.8s build + 3.0s test
MISSED   src/megolm/message.rs:50:54: replace + with * in 0.8s build + 3.2s test
MISSED   src/megolm/message.rs:54:9: replace MegolmMessage::ciphertext -> &[u8] with Vec::leak(Vec::new()) in 0.8s build + 3.0s test
MISSED   src/megolm/message.rs:54:9: replace MegolmMessage::ciphertext -> &[u8] with Vec::leak(vec![0]) in 0.8s build + 3.4s test
MISSED   src/megolm/message.rs:54:9: replace MegolmMessage::ciphertext -> &[u8] with Vec::leak(vec![1]) in 0.8s build + 3.0s test
MISSED   src/megolm/message.rs:59:9: replace MegolmMessage::message_index -> u32 with 0 in 0.8s build + 2.9s test
MISSED   src/megolm/message.rs:59:9: replace MegolmMessage::message_index -> u32 with 1 in 0.8s build + 3.0s test
MISSED   src/megolm/message.rs:64:9: replace MegolmMessage::mac -> &[u8] with Vec::leak(Vec::new()) in 0.8s build + 3.1s test
MISSED   src/megolm/message.rs:64:9: replace MegolmMessage::mac -> &[u8] with Vec::leak(vec![0]) in 0.8s build + 3.2s test
MISSED   src/megolm/message.rs:64:9: replace MegolmMessage::mac -> &[u8] with Vec::leak(vec![1]) in 0.9s build + 3.3s test
MISSED   src/megolm/mod.rs:34:5: replace default_config -> SessionConfig with Default::default() in 0.8s build + 3.2s test
MISSED   src/megolm/ratchet.rs:218:31: replace < with == in Ratchet::advance_to in 0.7s build + 3.0s test
MISSED   src/megolm/session_config.rs:33:9: replace SessionConfig::version -> u8 with 0 in 0.8s build + 3.0s test
MISSED   src/megolm/session_config.rs:33:9: replace SessionConfig::version -> u8 with 1 in 0.8s build + 3.5s test
MISSED   src/megolm/session_keys.rs:141:9: replace <impl Zeroize for ExportedSessionKey>::zeroize with () in 1.0s build + 3.2s test
MISSED   src/megolm/session_keys.rs:291:9: replace <impl Zeroize for SessionKey>::zeroize with () in 0.9s build + 3.2s test
TIMEOUT  src/megolm/ratchet.rs:230:23: replace -= with += in Ratchet::advance_to in 0.8s build + 23.0s test
TIMEOUT  src/megolm/ratchet.rs:230:23: replace -= with /= in Ratchet::advance_to in 0.8s build + 23.0s test

This also gets us to +90% coverage. 🙂

Relates to: #78

@codecov-commenter
Copy link

codecov-commenter commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.47%. Comparing base (7d51bd6) to head (b71c7c7).
Report is 4 commits behind head on main.

❗ Current head b71c7c7 differs from pull request most recent head 1f1d3f1. Consider uploading reports for the commit 1f1d3f1 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #142      +/-   ##
==========================================
+ Coverage   89.41%   90.47%   +1.05%     
==========================================
  Files          32       32              
  Lines        1786     1785       -1     
==========================================
+ Hits         1597     1615      +18     
+ Misses        189      170      -19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Johennes
Copy link
Contributor Author

Johennes commented Apr 9, 2024

Looks like the clippy errors are due to a new rule on nightly.

Edit: Attempting to fix them in #145.

@Johennes Johennes requested review from dkasak and poljar as code owners April 20, 2024 07:41
This was referenced Apr 22, 2024
Copy link
Collaborator

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though there's a stray println left over.

src/megolm/message.rs Outdated Show resolved Hide resolved
@Johennes
Copy link
Contributor Author

Johennes commented Apr 29, 2024

Hm, looks like the CI ran on an ARM Mac

Image: macos-14-arm64

but then installed the x86 rust toolchain

Run rustup toolchain install stable-x86_64-apple-darwin --profile minimal --no-self-update

which results in

/Users/runner/work/_temp/39f7e4d6-3a3c-42b0-9e65-200e32c1e151.sh: line 1: cargo: command not found

🤔

@Johennes
Copy link
Contributor Author

So according to https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-private-repositories macos-latest currently aliases macos-14 and always runs on M1. I'm not sure what suddenly changed here because last week it still resolved to macos-12 as evidenced by https://github.com/matrix-org/vodozemac/actions/runs/8779442225/job/24087554656#step:1:8.

@poljar do you want CI for macOS to run on both x86 and ARM Mac or would just ARM be enough?

@poljar
Copy link
Collaborator

poljar commented Apr 29, 2024

So according to https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-private-repositories macos-latest currently aliases macos-14 and always runs on M1. I'm not sure what suddenly changed here because last week it still resolved to macos-12 as evidenced by https://github.com/matrix-org/vodozemac/actions/runs/8779442225/job/24087554656#step:1:8.

@poljar do you want CI for macOS to run on both x86 and ARM Mac or would just ARM be enough?

Hmm, obviously both are better, but I'm happy to have any CI for Mac. So ARM only would be enough.

@Johennes Johennes force-pushed the johannes/megolm-mutation-tests branch 4 times, most recently from 02f8a6d to 1f1d3f1 Compare April 29, 2024 09:07
@Johennes Johennes force-pushed the johannes/megolm-mutation-tests branch from 1f1d3f1 to 7fde6e6 Compare April 29, 2024 11:49
@Johennes
Copy link
Contributor Author

Hmm, obviously both are better, but I'm happy to have any CI for Mac. So ARM only would be enough.

Since the CI job was already set up via a matrix strategy, it was actually pretty easy to just build on both. I hope it's ok that I added the small change in this PR directly.

@Johennes Johennes requested a review from poljar April 29, 2024 12:07
@poljar
Copy link
Collaborator

poljar commented Apr 29, 2024

Hmm, obviously both are better, but I'm happy to have any CI for Mac. So ARM only would be enough.

Since the CI job was already set up via a matrix strategy, it was actually pretty easy to just build on both. I hope it's ok that I added the small change in this PR directly.

Yeah that's fine.

@Johennes
Copy link
Contributor Author

I don't know why codecov is hanging now. I already tried it three or four times by now. 🤷‍♂️

@poljar
Copy link
Collaborator

poljar commented Apr 29, 2024

I don't know why codecov is hanging now. I already tried it three or four times by now. 🤷‍♂️

Hmm, no idea either. Maybe it'll untangle itself once merged.

@poljar poljar merged commit 420ce82 into matrix-org:main Apr 29, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants